#include "glwidget.h"
#include "id_generator.h"
#include <QApplication>
#include <QGLContext>

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  Scene scene;
  Controller controller(scene);

  QGLFormat format;
  format.setAlpha(true);
  format.setSampleBuffers(false);
  QGLContext* context = new QGLContext(format);

  GLWidget w(controller, context);
  controller.registerOutputDevice(&w);
  IdGenerator& gen = IdGenerator::getInstance();
  scene.setBackgroundColor(Material(0.0, 0.0, 0.0, 1.0));
  scene.addElement(new Cylinder(gen(), Vector3(0.0, 1.0, 0.0), 2.0, 0.2, Vector3f::Y(), Material(0.0, 0.0, 1.0, 1.0) ));
  scene.addElement(new Sphere(gen(), Vector3(0.0, 0.0, 0.0), 1.0, Material(1.0, 0.0, 0.0, 1.0)));
  scene.camera().setTarget(Vector3(0.0, 0.0, 0.0));
  scene.camera().setDistance(3.0);
  w.resize(800, 600);
  w.show();
  w.updateAll();
  
  return a.exec();
}
